package vg.services.graph_view_manager.realization.graph_view.smart_graph_view.realization.actions;

import vg.services.graph_layout_manager.interfaces.IGraphLayout;
import vg.services.graph_view_manager.interfaces.graph_view.IGraphRenderer;
import vg.services.main_manager.VGMainServiceHelper;
import vg.services.progress_manager.interfaces.IProgressTask;

/**
 * Executes current layout.
 *
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class ExecuteLayoutAction extends DefaultActionAdapter {
	public ExecuteLayoutAction() {
		super("Execute layout");
	}

    @Override
    public void noEDTAction(IGraphRenderer graphRenderer) {
        IGraphLayout currentLayout = VGMainServiceHelper.graphLayoutManager.getCurrentLayout();

        if (currentLayout != null) {
            currentLayout.execute(graphRenderer);
        } else {
            VGMainServiceHelper.logger.printError("Current layout is null");
        }
    }

	@Override
	public IProgressTask getProgressTask() {
		return null;
	}
}

